{% load navigation_tags %}
{% load display_tags %}
{% load static %}
<tr>
    {% if similar_finding.duplicate_finding == finding_context %}
        <td title="The finding on the top of this page is the original for this related finding">Duplicate{% if finding_context == similar_finding %}(this){% endif %}</td>
    {% elif finding_context.duplicate_finding == similar_finding %}
        <td title="The finding on the top of this page is a duplicate of this so called original finding">Original{% if finding_context == similar_finding %} (this){% endif %}</td>
    {% elif similar_finding.duplicate and similar_finding.duplicate_finding == finding_context.duplicate_finding %}
        <td title="This finding is a duplicate of the same original above">Duplicate{% if finding_context == similar_finding %}(this){% endif %}</td>
    {% elif not similar_finding.duplicate and similar_finding == finding_context %}
        <td title="This finding is the original of the cluster">Original{% if finding_context == similar_finding %}(this){% endif %}</td>
    {% else %}
        <td title="This finding shares fields values with the finding on this page because of which it looks similar">Similar</td>
    {% endif %}
    <td class="centered" data-order="{% severity_number_value similar_finding.severity %}">
        <span class="badge severity-{{ similar_finding.severity }}">
            {{ similar_finding.severity_display }}
        </span>
    </td>
    <td>
        <a title="{{ similar_finding.title }}" href="{% url 'view_finding' similar_finding.id %}">{{ similar_finding.title|truncatechars_html:80 }}</a>
        {% if similar_finding.tags %}
        <small>
            {% include "dojo/snippets/tags.html" with tags=similar_finding.tags.all %}
        </small>
        {% endif %}
        {% with similar_finding.notes.count as note_count %}
            ({{ note_count }} note{{ note_count|pluralize }})
        {% endwith %}
    </td>
    <td class="nowrap">{{ similar_finding.date|date }}</td>
    <td>{{ similar_finding|finding_display_status|safe }}&nbsp;{{ similar_finding|import_history }}</td>
    <td><a href="{% url 'view_test' similar_finding.test_id %}">{{ similar_finding.test }}</a></td>
    <td><a href="{% url 'view_engagement' similar_finding.test.engagement_id %}">{{ similar_finding.test.engagement.name }}</a>
    {% if similar_finding.test.engagement.version %}
        <sup>
                <a target="_blank" class="tag-label tag-version" data-toggle="tooltip" data-placement="bottom" title="Product Version: {{ similar_finding.test.engagement.version }}">
                {{ similar_finding.test.engagement.version }}</a>
        </sup>
    {% endif %}
    </td>
    <td>
        {% if similar_finding.cwe > 0 %}
        <a target="_blank" href="{{ similar_finding.cwe|cwe_url }}">
            <i class="fa-solid fa-arrow-up-right-from-square"></i> {{ similar_finding.cwe }}
        </a>
        {% endif %}
    </td>
    <td>{{ similar_finding.cve }}</td>
    <td>{{ similar_finding.epss_score|format_epss }}</td>
    <td>{{ similar_finding.epss_percentile|format_epss }}</td>
    {% if similar_finding.file_path %}
        <td title="{{similar_finding.file_path}}{% if similar_finding.line > 0 %} (Line {{ similar_finding.line }}){% endif %}">
            {{ similar_finding.file_path|truncatechars_html:20 }}{% if similar_finding.line > 0 %} (Line {{ similar_finding.line }}){% endif %}
            <i class="fa-solid fa-copy fa-align-right copytoclipboard" title="copy full path to clipboard"
            data-clipboard-text="{{similar_finding.file_path}}{% if similar_finding.line > 0 %} (Line {{ similar_finding.line }}){% endif %}"></i></td>
    {% else %}
        <td></td>
    {% endif%}

    {% if system_settings.enable_jira %}
        <td>
            {% if similar_finding.jira_issue %}
                <a href="{{ similar_finding | jira_issue_url }}"
                target="_blank" title="{{similar_finding | jira_issue_url }}">{{ similar_finding | jira_key }}</a>
            {% endif %}
        </td>
    {% endif %}

    <td>
        {% include "dojo/finding_related_actions.html" with similar_finding=similar_finding finding_context=finding %}
    </td>
</tr>
